var name;
var password;

$("#update").click(function () {
    var str = document.getElementById("update").outerText;
    var oldPassword = $("#password").val();
    var UPpassword = $("#UPpassword").val();
    var TUPpassword = $("#TUPpassword").val();

    UpwdHand();

})

function getpwdData() {
    return new Promise((resolve, reject) => {
        $.ajax({
            type: "post",
            data: {
                "name": name,
                "password": password
            },
            url: "http://localhost:8087/tbuser/upUInfo",
            dataType: "json",
            success: function (udpwd) {
                console.log(udpwd)
                resolve(udpwd)
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                reject("查询失败");
            }
        });
    });
}

if (document.readyState !== 'loading') {
    UpwdHand();
} else {
    document.addEventListener('DOMContentLoaded', UpwdHand);
}

async function UpwdHand() {
    var table = document.getElementById("Upwd");
    var mydata = await getpwdData();
    var result = '';
    console.log("pwd" + mydata);
    var myhtml =` 
        <form action="/modify"  id="lg-form" name="lg-form" method="post">
        <table class="grinfo">
        <tbody >
        <tr>
        <th>原手机号：</th>
        <td> <strong>${mydata.id}</strong></td>
        </tr>
        <tr>
        <th>昵称：</th>
        <td>
            <input class="inp inw" type="text" id="new_username" maxlength="15" placeholder="不少于3位中英文即可" value="" onkeyup="return only_py_num(this)">
        </td>
        </tr>
        <tr>
        <th>新密码：</th>
        <td>
        <input class="inp inw" type="password" id="password" placeholder="不少于6位">
        </td>
        </tr>
        <tr>
        <th>重复新密码：</th>
        <td>
        <input class="inp inw" type="password" id="newPassword" placeholder="不少于6位">
        </td>
        </tr>
        <tr>
        <th>&nbsp;</th>
        <td colspan="2">
        <label class="butt" id="butt">
        <div class="member_mod_buttom" onclick="sub_username()">完成修改</div>
        </label>
        </td>
        </tr>
        </tbody></table></form>`;
    result += myhtml;
    table.innerHTML = result;

}